@extends('admin.layout')
@section('content')
    @if ($message = Session::get('success'))
        <div class="layui-card">
            <div class="layui-card-header">提示！</div>
            <div class="layui-card-body">
                <p>{{ $message }}</p>
            </div>
        </div>
    @endif
    <div class="layui-card">
        <div class="layui-card-header">
            <form  class="layui-form" >
                <div class="layui-form-item">
                    <div class="layui-input-inline">
                        <input type="text" name="name" value="" autocomplete="off" placeholder="请输入标题" class="layui-input"/>
                    </div>

                    <div class="layui-input-inline" style="width: 50px;">
                        <button class="layui-btn layui-btn-primary " lay-submit lay-filter="search"><i class="fa fa-search"></i></button>
                    </div>
                </div>
            </form>
            <div class="layui-btn-group layui-left-menu">
                <a  href="{{route('admin.goods.brand.create')}}" class="layui-btn ajax-popup"><i class="fa fa-plus-circle"></i> 添加品牌</a>
                <a  href="{{route('admin.goods.brand.destroy')}}" class="layui-btn layui-btn-danger ajax-batch-del"><i class="fa fa-trash-o"></i> 批量删除</a>

            </div>
        </div>
        <div class="layui-card-body">
            <table id="dataTable" lay-filter="dataTable"></table>
            <script type="text/html" id="options">
                <div class="layui-btn-group">
                        <a class="layui-btn layui-btn-sm ajax-popup" href="/admin/goods/brand/edit/@{{d.id}}/" lay-event="edit">编辑</a>
                        <a  class="layui-btn layui-btn-danger layui-btn-sm ajax-del" href="{{route('admin.goods.brand.destroy')}}" data-id="@{{d.id}}" >删除</a>
                </div>
            </script>
        </div>
    </div>
@endsection

@section('script')
    <script>
        layui.use(['table','form','layer'], function(){
           var table = layui.table;
            var dataTable = table.render({
                elem: '#dataTable'
                ,url: "{{ route('admin.goods.brand.data') }}" //数据接口
                ,page: true //开启分页
                ,cols: [[ //表头
                    {checkbox: true,fixed: true}
                    ,{field: 'id', title: 'ID', sort: true,width:80}
                    ,{field: 'name', title: '名称'}
                    ,{field: 'type', title: 'logo', templet: function(data){
                        return '<a  class="view-img" href="'+data.logo+'" ><image style="max-width:30px;max-height:30px;" src="'+data.logo+'"/></a>';
                    }}
                    ,{field: 'value', title: '排序'}
                    ,{fixed: 'right',  align:'center', toolbar: '#options'}
                ]]
            });
        });
    </script>
@endsection